﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sispe.Entities;
using Sispe.Repository;
using Microsoft.Practices.Unity;

namespace Sispe.BussinesLogic
{
    public class ExpedienteBL : IExpedienteBL
    {
        [Dependency]
        public IExpedienteRepository expedienteDAO { get; set; }

        public void deleteDetalle(int idDet)
        {
            expedienteDAO.deleteDetalle(idDet);
        }

        public List<EXPEDIENTE> GetAllFromTrabajadorExpediente()
        {
            return expedienteDAO.GetAllFromTrabajadorExpediente();
        }

        public List<EXPEDIENTE> GetAllFromTrabajadorExpedienteByTrabajadorId(int id)
        {
            return expedienteDAO.GetAllFromTrabajadorExpedienteByTrabajadorId(id);
        }

        public void AddExpedienteNuevo(EXPEDIENTE expediente)
        {
            var msg = "";

            var ok = expediente.Validate(out msg);
            if (ok)
            {
                expedienteDAO.AddExpedienteNuevo(expediente);
            }
            else
            {
                throw new Exception(msg);
            }
            
        }
    }
}
